<?php
class content_update {
	var $modelid;
	var $fields;
	var $contentid;
	var $data;

    function __construct($modelid) {
		$db = xt_load('db','icweb');
		$this->db = &$db;
		$this->modelid = $modelid;
		$this->fields = xt_readcache('fields_'.$this->modelid.'.cache.php', MS_CACHEPATH.'model/');
    }

	/*function content_update($modelid, $contentid)
	{
		$this->__construct($modelid, $contentid);
	}*/

	function update($data) {
		$info = array();
		$this->data = $data;
		foreach($data as $field=>$value) {
			if(!isset($this->fields[$field])) continue;
			$func = $this->fields[$field]['formtype'];
			$info[$field] = method_exists($this, $func) ? $this->$func($field, $value) : $value;
		}
		return $info;
	}

}?>